<?php
define('URI', 'http://' . $_SERVER['HTTP_HOST'] . substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], 'index.php')));
$fileNames = array(
    'default'       => 'part_default.php',
    'evenementiel'  => 'part_evenementiel.php',
    'travaux'       => 'part_travaux.php',
    'ceremonies'    => 'part_ceremonies.php',
    'portraits'     => 'part_portraits.php',
    'bio'           => 'part_bio.php',
    'contact'       => 'part_contact'
);

$fileTitles = array(
    'default'       => null,
    'evenementiel'  => 'Évenementiel',
    'travaux'       => 'Travaux',
    'ceremonies'    => 'Cérémonies',
    'portraits'     => 'Portraits',
    'bio'           => 'Biographie',
    'contact'       => 'Contact'    
);

$_CATEGORY  = (empty($_GET['cat']) OR !isset($fileNames[$_GET['cat']])) ? 'default' : $_GET['cat'];
$_TITLE     = $fileTitles[$_CATEGORY];


// PART 
$path = __DIR__ . '/' . $fileNames[$_CATEGORY];
ob_start();
if ( file_exists($path) ) { 
  include $path ;
}
$_CONTENTS = ob_get_contents();
ob_end_clean();

// LAYOUT

if ( isset($_POST['ajax']) AND $_POST['ajax'] === "true" ) {
  echo $_CONTENTS;
}
else {
  $path = __DIR__ . '/layout.php';
  ob_start();
  if ( file_exists($path) ) { 
    include $path ;
  }
  ob_end_flush();
}